package com.yan.community.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.yan.club.result.Result;
import com.yan.community.dto.CommunityCategoryDto;
import com.yan.community.model.ClubCommunityCategory;
import com.yan.community.service.CommunityCategoryService;

/**
 * @author 彦
 * @since 2023/12/12 10:34
 * 社团种类管理
 */
@RestController
@RequestMapping("/community/category")
public class CommunityCategoryController {

    @Resource
    private CommunityCategoryService clubCategoryService;

    /**
     * 得到全部社团分类
     *
     * @param clubCategoryDto
     * @return
     */
    @PostMapping("/page")
    public Result<PageInfo<ClubCommunityCategory>> getAllCategory(@RequestBody CommunityCategoryDto clubCategoryDto) {
        return clubCategoryService.getAllCategory(clubCategoryDto);
    }

    /**
     * 新增 / 修改
     *
     * @return
     */
    @PostMapping("/saveCategory")
    public Result<String> saveCategory(@RequestBody ClubCommunityCategory clubCategory) {
        return clubCategoryService.saveCategory(clubCategory);
    }

    /**
     * 根据ID查询种类
     * @param id
     * @return
     */
    @GetMapping("/getCateGoryById")
    public Result<ClubCommunityCategory> getCateGoryById(@RequestParam Long id) {
        return clubCategoryService.getCateGoryById(id);
    }

    /**
     * 逻辑删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/delCategory")
    public Result<String> delCategory(@RequestParam Long id) {
        return clubCategoryService.delCategory(id);
    }
}
